{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e94f9d69-eb55-4916-8a9f-f8bca104b022",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import svm\n",
    "import pandas as pd\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "from sklearn.ensemble import GradientBoostingClassifier\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.ensemble import RandomForestClassifier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "990260f1-915d-4f78-adb8-a383220c2c16",
   "metadata": {},
   "outputs": [],
   "source": [
    "data=pd.read_csv('./data/result11.csv')\n",
    "data=data[data['v_Vel']!=0]\n",
    "data=data[data['v_Class']==2]\n",
    "d1 = data[data['label']==0]\n",
    "d1=d1.sample(n=280,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "58afcef8-9175-42a4-bd98-8b2911f173cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2=data[data['label']==1]\n",
    "d2=d2.sample(n=280,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6dec30a6-9ff7-429e-9890-3adcaa0f544e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Vehicle_ID</th>\n",
       "      <th>Frame_ID</th>\n",
       "      <th>Local_X</th>\n",
       "      <th>Local_Y</th>\n",
       "      <th>v_Class</th>\n",
       "      <th>v_Vel</th>\n",
       "      <th>v_Acc</th>\n",
       "      <th>Lane_ID</th>\n",
       "      <th>x_a</th>\n",
       "      <th>label1</th>\n",
       "      <th>v1</th>\n",
       "      <th>v2</th>\n",
       "      <th>v3</th>\n",
       "      <th>v4</th>\n",
       "      <th>y1</th>\n",
       "      <th>y2</th>\n",
       "      <th>y3</th>\n",
       "      <th>y4</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1876</td>\n",
       "      <td>7537</td>\n",
       "      <td>30.578</td>\n",
       "      <td>1368.250033</td>\n",
       "      <td>2</td>\n",
       "      <td>14.120490</td>\n",
       "      <td>4.412131</td>\n",
       "      <td>3</td>\n",
       "      <td>-0.37</td>\n",
       "      <td>0</td>\n",
       "      <td>-5.849992</td>\n",
       "      <td>3.457524</td>\n",
       "      <td>10.215352</td>\n",
       "      <td>4.992463</td>\n",
       "      <td>39.606223</td>\n",
       "      <td>-48.158408</td>\n",
       "      <td>34.881723</td>\n",
       "      <td>-23.962125</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>145</td>\n",
       "      <td>1032</td>\n",
       "      <td>31.014</td>\n",
       "      <td>441.999317</td>\n",
       "      <td>2</td>\n",
       "      <td>30.762008</td>\n",
       "      <td>-0.110211</td>\n",
       "      <td>3</td>\n",
       "      <td>0.67</td>\n",
       "      <td>0</td>\n",
       "      <td>1.573340</td>\n",
       "      <td>-0.981617</td>\n",
       "      <td>-2.883444</td>\n",
       "      <td>-6.268600</td>\n",
       "      <td>57.858087</td>\n",
       "      <td>-74.076397</td>\n",
       "      <td>37.697755</td>\n",
       "      <td>-15.125006</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>57</td>\n",
       "      <td>758</td>\n",
       "      <td>40.636</td>\n",
       "      <td>719.827946</td>\n",
       "      <td>2</td>\n",
       "      <td>26.061473</td>\n",
       "      <td>0.660512</td>\n",
       "      <td>4</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>0</td>\n",
       "      <td>-5.717530</td>\n",
       "      <td>-0.485004</td>\n",
       "      <td>1.270773</td>\n",
       "      <td>0.202663</td>\n",
       "      <td>82.100202</td>\n",
       "      <td>-59.568075</td>\n",
       "      <td>9.685042</td>\n",
       "      <td>-34.865091</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1330</td>\n",
       "      <td>5542</td>\n",
       "      <td>5.447</td>\n",
       "      <td>1042.491264</td>\n",
       "      <td>2</td>\n",
       "      <td>40.969247</td>\n",
       "      <td>-1.082507</td>\n",
       "      <td>1</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0</td>\n",
       "      <td>7.857953</td>\n",
       "      <td>-0.077109</td>\n",
       "      <td>-6.575135</td>\n",
       "      <td>-6.742938</td>\n",
       "      <td>76.423901</td>\n",
       "      <td>-61.650939</td>\n",
       "      <td>45.141825</td>\n",
       "      <td>-19.214096</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>772</td>\n",
       "      <td>3744</td>\n",
       "      <td>7.679</td>\n",
       "      <td>791.969313</td>\n",
       "      <td>2</td>\n",
       "      <td>25.510004</td>\n",
       "      <td>-0.611958</td>\n",
       "      <td>1</td>\n",
       "      <td>-0.16</td>\n",
       "      <td>0</td>\n",
       "      <td>2.569478</td>\n",
       "      <td>-2.762512</td>\n",
       "      <td>-7.754914</td>\n",
       "      <td>-10.401798</td>\n",
       "      <td>65.630370</td>\n",
       "      <td>-89.321986</td>\n",
       "      <td>7.258815</td>\n",
       "      <td>-25.473264</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>555</th>\n",
       "      <td>920</td>\n",
       "      <td>4218</td>\n",
       "      <td>39.931</td>\n",
       "      <td>698.158835</td>\n",
       "      <td>2</td>\n",
       "      <td>24.542434</td>\n",
       "      <td>-1.447911</td>\n",
       "      <td>4</td>\n",
       "      <td>-0.90</td>\n",
       "      <td>1</td>\n",
       "      <td>0.465384</td>\n",
       "      <td>-3.738641</td>\n",
       "      <td>6.250516</td>\n",
       "      <td>5.787188</td>\n",
       "      <td>52.811074</td>\n",
       "      <td>-52.759624</td>\n",
       "      <td>10.571570</td>\n",
       "      <td>-63.914156</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>556</th>\n",
       "      <td>847</td>\n",
       "      <td>4310</td>\n",
       "      <td>41.675</td>\n",
       "      <td>1706.182401</td>\n",
       "      <td>2</td>\n",
       "      <td>40.245340</td>\n",
       "      <td>-0.177768</td>\n",
       "      <td>4</td>\n",
       "      <td>-0.62</td>\n",
       "      <td>1</td>\n",
       "      <td>2.107818</td>\n",
       "      <td>-4.335687</td>\n",
       "      <td>7.493740</td>\n",
       "      <td>4.638287</td>\n",
       "      <td>72.229795</td>\n",
       "      <td>-80.221946</td>\n",
       "      <td>2.371845</td>\n",
       "      <td>-97.777584</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>557</th>\n",
       "      <td>1147</td>\n",
       "      <td>4904</td>\n",
       "      <td>30.118</td>\n",
       "      <td>511.131912</td>\n",
       "      <td>2</td>\n",
       "      <td>41.125179</td>\n",
       "      <td>1.663810</td>\n",
       "      <td>3</td>\n",
       "      <td>-0.14</td>\n",
       "      <td>1</td>\n",
       "      <td>-5.254088</td>\n",
       "      <td>0.814919</td>\n",
       "      <td>-3.318836</td>\n",
       "      <td>-4.609949</td>\n",
       "      <td>114.603071</td>\n",
       "      <td>-47.471009</td>\n",
       "      <td>0.924743</td>\n",
       "      <td>-104.730191</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>558</th>\n",
       "      <td>1057</td>\n",
       "      <td>4729</td>\n",
       "      <td>50.141</td>\n",
       "      <td>927.075425</td>\n",
       "      <td>2</td>\n",
       "      <td>37.351599</td>\n",
       "      <td>2.442020</td>\n",
       "      <td>5</td>\n",
       "      <td>-0.71</td>\n",
       "      <td>1</td>\n",
       "      <td>-1.533239</td>\n",
       "      <td>3.065689</td>\n",
       "      <td>6.229978</td>\n",
       "      <td>3.339638</td>\n",
       "      <td>68.183166</td>\n",
       "      <td>-248.908756</td>\n",
       "      <td>108.392519</td>\n",
       "      <td>-85.400442</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>559</th>\n",
       "      <td>858</td>\n",
       "      <td>4151</td>\n",
       "      <td>51.955</td>\n",
       "      <td>931.961649</td>\n",
       "      <td>2</td>\n",
       "      <td>29.842854</td>\n",
       "      <td>0.149944</td>\n",
       "      <td>5</td>\n",
       "      <td>0.07</td>\n",
       "      <td>1</td>\n",
       "      <td>-4.503351</td>\n",
       "      <td>-0.064640</td>\n",
       "      <td>5.848472</td>\n",
       "      <td>2.542192</td>\n",
       "      <td>63.005937</td>\n",
       "      <td>-22.413219</td>\n",
       "      <td>2.767773</td>\n",
       "      <td>-66.362343</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>560 rows × 19 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Vehicle_ID  Frame_ID  Local_X      Local_Y  v_Class      v_Vel     v_Acc  \\\n",
       "0          1876      7537   30.578  1368.250033        2  14.120490  4.412131   \n",
       "1           145      1032   31.014   441.999317        2  30.762008 -0.110211   \n",
       "2            57       758   40.636   719.827946        2  26.061473  0.660512   \n",
       "3          1330      5542    5.447  1042.491264        2  40.969247 -1.082507   \n",
       "4           772      3744    7.679   791.969313        2  25.510004 -0.611958   \n",
       "..          ...       ...      ...          ...      ...        ...       ...   \n",
       "555         920      4218   39.931   698.158835        2  24.542434 -1.447911   \n",
       "556         847      4310   41.675  1706.182401        2  40.245340 -0.177768   \n",
       "557        1147      4904   30.118   511.131912        2  41.125179  1.663810   \n",
       "558        1057      4729   50.141   927.075425        2  37.351599  2.442020   \n",
       "559         858      4151   51.955   931.961649        2  29.842854  0.149944   \n",
       "\n",
       "     Lane_ID   x_a  label1        v1        v2         v3         v4  \\\n",
       "0          3 -0.37       0 -5.849992  3.457524  10.215352   4.992463   \n",
       "1          3  0.67       0  1.573340 -0.981617  -2.883444  -6.268600   \n",
       "2          4 -0.15       0 -5.717530 -0.485004   1.270773   0.202663   \n",
       "3          1  0.07       0  7.857953 -0.077109  -6.575135  -6.742938   \n",
       "4          1 -0.16       0  2.569478 -2.762512  -7.754914 -10.401798   \n",
       "..       ...   ...     ...       ...       ...        ...        ...   \n",
       "555        4 -0.90       1  0.465384 -3.738641   6.250516   5.787188   \n",
       "556        4 -0.62       1  2.107818 -4.335687   7.493740   4.638287   \n",
       "557        3 -0.14       1 -5.254088  0.814919  -3.318836  -4.609949   \n",
       "558        5 -0.71       1 -1.533239  3.065689   6.229978   3.339638   \n",
       "559        5  0.07       1 -4.503351 -0.064640   5.848472   2.542192   \n",
       "\n",
       "             y1          y2          y3          y4  label  \n",
       "0     39.606223  -48.158408   34.881723  -23.962125    0.0  \n",
       "1     57.858087  -74.076397   37.697755  -15.125006    0.0  \n",
       "2     82.100202  -59.568075    9.685042  -34.865091    0.0  \n",
       "3     76.423901  -61.650939   45.141825  -19.214096    0.0  \n",
       "4     65.630370  -89.321986    7.258815  -25.473264    0.0  \n",
       "..          ...         ...         ...         ...    ...  \n",
       "555   52.811074  -52.759624   10.571570  -63.914156    1.0  \n",
       "556   72.229795  -80.221946    2.371845  -97.777584    1.0  \n",
       "557  114.603071  -47.471009    0.924743 -104.730191    1.0  \n",
       "558   68.183166 -248.908756  108.392519  -85.400442    1.0  \n",
       "559   63.005937  -22.413219    2.767773  -66.362343    1.0  \n",
       "\n",
       "[560 rows x 19 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data=pd.concat([d1,d2],ignore_index=True)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b6c70c1b-b4b2-423b-ab60-d4a70bb2465c",
   "metadata": {},
   "outputs": [],
   "source": [
    "x=data[['v_Vel','v1','v2','v3','v4','y1','y2','y3','y4']]\n",
    "y=data[\"label\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "8f44ac63-195f-44e7-9d10-b465b11cdefa",
   "metadata": {},
   "outputs": [],
   "source": [
    "x_train, x_test, y_train, y_test = train_test_split(x,y, test_size=0.2,random_state=22)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "0ddd24b5-305d-4c49-adff-f4a332dc9d96",
   "metadata": {},
   "outputs": [],
   "source": [
    "transfer=StandardScaler()\n",
    "x_train=transfer.fit_transform(x_train)\n",
    "x_test=transfer.transform(x_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "78b84fb1-7e5c-4fb8-9e11-48d2f159ddbe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-container-id-1 {\n",
       "  /* Definition of color scheme common for light and dark mode */\n",
       "  --sklearn-color-text: black;\n",
       "  --sklearn-color-line: gray;\n",
       "  /* Definition of color scheme for unfitted estimators */\n",
       "  --sklearn-color-unfitted-level-0: #fff5e6;\n",
       "  --sklearn-color-unfitted-level-1: #f6e4d2;\n",
       "  --sklearn-color-unfitted-level-2: #ffe0b3;\n",
       "  --sklearn-color-unfitted-level-3: chocolate;\n",
       "  /* Definition of color scheme for fitted estimators */\n",
       "  --sklearn-color-fitted-level-0: #f0f8ff;\n",
       "  --sklearn-color-fitted-level-1: #d4ebff;\n",
       "  --sklearn-color-fitted-level-2: #b3dbfd;\n",
       "  --sklearn-color-fitted-level-3: cornflowerblue;\n",
       "\n",
       "  /* Specific color for light theme */\n",
       "  --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
       "  --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
       "  --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
       "  --sklearn-color-icon: #696969;\n",
       "\n",
       "  @media (prefers-color-scheme: dark) {\n",
       "    /* Redefinition of color scheme for dark theme */\n",
       "    --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
       "    --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
       "    --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
       "    --sklearn-color-icon: #878787;\n",
       "  }\n",
       "}\n",
       "\n",
       "#sk-container-id-1 {\n",
       "  color: var(--sklearn-color-text);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 pre {\n",
       "  padding: 0;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-hidden--visually {\n",
       "  border: 0;\n",
       "  clip: rect(1px 1px 1px 1px);\n",
       "  clip: rect(1px, 1px, 1px, 1px);\n",
       "  height: 1px;\n",
       "  margin: -1px;\n",
       "  overflow: hidden;\n",
       "  padding: 0;\n",
       "  position: absolute;\n",
       "  width: 1px;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-dashed-wrapped {\n",
       "  border: 1px dashed var(--sklearn-color-line);\n",
       "  margin: 0 0.4em 0.5em 0.4em;\n",
       "  box-sizing: border-box;\n",
       "  padding-bottom: 0.4em;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-container {\n",
       "  /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
       "     but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
       "     so we also need the `!important` here to be able to override the\n",
       "     default hidden behavior on the sphinx rendered scikit-learn.org.\n",
       "     See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
       "  display: inline-block !important;\n",
       "  position: relative;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-text-repr-fallback {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       "div.sk-parallel-item,\n",
       "div.sk-serial,\n",
       "div.sk-item {\n",
       "  /* draw centered vertical line to link estimators */\n",
       "  background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
       "  background-size: 2px 100%;\n",
       "  background-repeat: no-repeat;\n",
       "  background-position: center center;\n",
       "}\n",
       "\n",
       "/* Parallel-specific style estimator block */\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item::after {\n",
       "  content: \"\";\n",
       "  width: 100%;\n",
       "  border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
       "  flex-grow: 1;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel {\n",
       "  display: flex;\n",
       "  align-items: stretch;\n",
       "  justify-content: center;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  position: relative;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item {\n",
       "  display: flex;\n",
       "  flex-direction: column;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:first-child::after {\n",
       "  align-self: flex-end;\n",
       "  width: 50%;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:last-child::after {\n",
       "  align-self: flex-start;\n",
       "  width: 50%;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:only-child::after {\n",
       "  width: 0;\n",
       "}\n",
       "\n",
       "/* Serial-specific style estimator block */\n",
       "\n",
       "#sk-container-id-1 div.sk-serial {\n",
       "  display: flex;\n",
       "  flex-direction: column;\n",
       "  align-items: center;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  padding-right: 1em;\n",
       "  padding-left: 1em;\n",
       "}\n",
       "\n",
       "\n",
       "/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
       "clickable and can be expanded/collapsed.\n",
       "- Pipeline and ColumnTransformer use this feature and define the default style\n",
       "- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
       "*/\n",
       "\n",
       "/* Pipeline and ColumnTransformer style (default) */\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable {\n",
       "  /* Default theme specific background. It is overwritten whether we have a\n",
       "  specific estimator or a Pipeline/ColumnTransformer */\n",
       "  background-color: var(--sklearn-color-background);\n",
       "}\n",
       "\n",
       "/* Toggleable label */\n",
       "#sk-container-id-1 label.sk-toggleable__label {\n",
       "  cursor: pointer;\n",
       "  display: block;\n",
       "  width: 100%;\n",
       "  margin-bottom: 0;\n",
       "  padding: 0.5em;\n",
       "  box-sizing: border-box;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
       "  /* Arrow on the left of the label */\n",
       "  content: \"▸\";\n",
       "  float: left;\n",
       "  margin-right: 0.25em;\n",
       "  color: var(--sklearn-color-icon);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n",
       "  color: var(--sklearn-color-text);\n",
       "}\n",
       "\n",
       "/* Toggleable content - dropdown */\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content {\n",
       "  max-height: 0;\n",
       "  max-width: 0;\n",
       "  overflow: hidden;\n",
       "  text-align: left;\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content.fitted {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content pre {\n",
       "  margin: 0.2em;\n",
       "  border-radius: 0.25em;\n",
       "  color: var(--sklearn-color-text);\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
       "  /* Expand drop-down */\n",
       "  max-height: 200px;\n",
       "  max-width: 100%;\n",
       "  overflow: auto;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
       "  content: \"▾\";\n",
       "}\n",
       "\n",
       "/* Pipeline/ColumnTransformer-specific style */\n",
       "\n",
       "#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Estimator-specific style */\n",
       "\n",
       "/* Colorize estimator box */\n",
       "#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n",
       "#sk-container-id-1 div.sk-label label {\n",
       "  /* The background is the default theme color */\n",
       "  color: var(--sklearn-color-text-on-default-background);\n",
       "}\n",
       "\n",
       "/* On hover, darken the color of the background */\n",
       "#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "/* Label box, darken color on hover, fitted */\n",
       "#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Estimator label */\n",
       "\n",
       "#sk-container-id-1 div.sk-label label {\n",
       "  font-family: monospace;\n",
       "  font-weight: bold;\n",
       "  display: inline-block;\n",
       "  line-height: 1.2em;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label-container {\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       "/* Estimator-specific */\n",
       "#sk-container-id-1 div.sk-estimator {\n",
       "  font-family: monospace;\n",
       "  border: 1px dotted var(--sklearn-color-border-box);\n",
       "  border-radius: 0.25em;\n",
       "  box-sizing: border-box;\n",
       "  margin-bottom: 0.5em;\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "/* on hover */\n",
       "#sk-container-id-1 div.sk-estimator:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
       "\n",
       "/* Common style for \"i\" and \"?\" */\n",
       "\n",
       ".sk-estimator-doc-link,\n",
       "a:link.sk-estimator-doc-link,\n",
       "a:visited.sk-estimator-doc-link {\n",
       "  float: right;\n",
       "  font-size: smaller;\n",
       "  line-height: 1em;\n",
       "  font-family: monospace;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  border-radius: 1em;\n",
       "  height: 1em;\n",
       "  width: 1em;\n",
       "  text-decoration: none !important;\n",
       "  margin-left: 1ex;\n",
       "  /* unfitted */\n",
       "  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-unfitted-level-1);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link.fitted,\n",
       "a:link.sk-estimator-doc-link.fitted,\n",
       "a:visited.sk-estimator-doc-link.fitted {\n",
       "  /* fitted */\n",
       "  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-fitted-level-1);\n",
       "}\n",
       "\n",
       "/* On hover */\n",
       "div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
       ".sk-estimator-doc-link:hover,\n",
       "div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
       ".sk-estimator-doc-link:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
       ".sk-estimator-doc-link.fitted:hover,\n",
       "div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
       ".sk-estimator-doc-link.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "/* Span, style for the box shown on hovering the info icon */\n",
       ".sk-estimator-doc-link span {\n",
       "  display: none;\n",
       "  z-index: 9999;\n",
       "  position: relative;\n",
       "  font-weight: normal;\n",
       "  right: .2ex;\n",
       "  padding: .5ex;\n",
       "  margin: .5ex;\n",
       "  width: min-content;\n",
       "  min-width: 20ex;\n",
       "  max-width: 50ex;\n",
       "  color: var(--sklearn-color-text);\n",
       "  box-shadow: 2pt 2pt 4pt #999;\n",
       "  /* unfitted */\n",
       "  background: var(--sklearn-color-unfitted-level-0);\n",
       "  border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link.fitted span {\n",
       "  /* fitted */\n",
       "  background: var(--sklearn-color-fitted-level-0);\n",
       "  border: var(--sklearn-color-fitted-level-3);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link:hover span {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       "/* \"?\"-specific style due to the `<a>` HTML tag */\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link {\n",
       "  float: right;\n",
       "  font-size: 1rem;\n",
       "  line-height: 1em;\n",
       "  font-family: monospace;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  border-radius: 1rem;\n",
       "  height: 1rem;\n",
       "  width: 1rem;\n",
       "  text-decoration: none;\n",
       "  /* unfitted */\n",
       "  color: var(--sklearn-color-unfitted-level-1);\n",
       "  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link.fitted {\n",
       "  /* fitted */\n",
       "  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-fitted-level-1);\n",
       "}\n",
       "\n",
       "/* On hover */\n",
       "#sk-container-id-1 a.estimator_doc_link:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-3);\n",
       "}\n",
       "</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>SVC()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow fitted\">&nbsp;&nbsp;SVC<a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.4/modules/generated/sklearn.svm.SVC.html\">?<span>Documentation for SVC</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></label><div class=\"sk-toggleable__content fitted\"><pre>SVC()</pre></div> </div></div></div></div>"
      ],
      "text/plain": [
       "SVC()"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf=svm.SVC()\n",
    "clf.fit(x_train,y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "fc819306-cc44-40b8-813e-8a4a957e175d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "准确率为：\n",
      " 0.7142857142857143\n"
     ]
    }
   ],
   "source": [
    "score=clf.score(x_test,y_test)\n",
    "print(\"准确率为：\\n\",score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7cf7e181-10b5-4724-bb57-651f0b67eead",
   "metadata": {},
   "outputs": [],
   "source": [
    "y_predict=clf.predict(x_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c67ae480-2206-4383-b4bf-a5becd4b689c",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.metrics import classification_report"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d58c9da8-7d4a-47ab-8c9f-1df4e40a1126",
   "metadata": {},
   "outputs": [],
   "source": [
    "t=classification_report(y_test,y_predict,target_names=['0','1'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "5ac1e1bd-dc54-465e-a656-081dfa96216f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.75      0.67      0.70        57\n",
      "           1       0.69      0.76      0.72        55\n",
      "\n",
      "    accuracy                           0.71       112\n",
      "   macro avg       0.72      0.72      0.71       112\n",
      "weighted avg       0.72      0.71      0.71       112\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ee52481f-56ee-4a26-bb5f-e65825506ca2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.8125\n"
     ]
    }
   ],
   "source": [
    "train_score=clf.score(x_train,y_train)\n",
    "print(train_score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "2282eab4-9b90-426c-bbe4-e772b2b358fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.83      0.79      0.81       223\n",
      "           1       0.80      0.84      0.82       225\n",
      "\n",
      "    accuracy                           0.81       448\n",
      "   macro avg       0.81      0.81      0.81       448\n",
      "weighted avg       0.81      0.81      0.81       448\n",
      "\n"
     ]
    }
   ],
   "source": [
    "y_predict1=clf.predict(x_train)\n",
    "train_t=classification_report(y_train,y_predict1,target_names=['0','1'])\n",
    "print(train_t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec7b1b34-6501-48bb-b16a-7c14f49da8af",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
